package com.ruoyi.common.utils;



import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

/**
 * 证码识别（图片名即为验证码数字）
 * @author drguo
 *
 */
public class VCRUtil {
	public static void main(String[] args) throws IOException {
		// 创建实例
		ITesseract instance = new Tesseract();

		// 设置识别语言

		//instance.setLanguage("chi_sim");
		//
		//// 设置识别引擎
		//
		//instance.setOcrEngineMode(1);

		// 读取文件

		BufferedImage image = ImageIO.read(new File("E:\\sanzhi\\农商银行\\0056.png"));
		try {

			// 识别

			String result = instance.doOCR(image);
			System.out.println(result);
		} catch (TesseractException e) {
			System.err.println(e.getMessage());
		}
    }
}
